﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class user_follow_page : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ctp_lib.check_login(this.Page, "user/follow.aspx", false);

        ctpDataContext db = new ctpDataContext();


        var following = from aa in db.user_follows
                where   aa.create_user_no == (int)Session["userno"]
                orderby aa.addtime descending
                select aa;


        var follower = from p in db.user_follows
                       join q in db.users on p.create_user_no equals q.no
                       where p.follow_who == (int)Session["userno"]
                       orderby p.addtime descending
                       select new
                       {
                           nickname = q.nickname,
                           profile_picture = q.profile_picture,
                           no = p.create_user_no

                       };

        //var follower = from aa in db.user_follows
        //                where aa.follow_who == (int)Session["userno"]
        //                orderby aa.addtime descending
        //                select aa;

        this.Label1.Text = following.Count().ToString();
        this.Label2.Text = follower.Count().ToString();



        foreach (user_follow u in following)
        {
            if (u.user.profile_picture == null)
                u.user.profile_picture = "coming.gif";
            else
                u.user.profile_picture = u.user.profile_picture.Trim();


        }



        this.DataList3.DataSource = following;
        this.DataList4.DataSource = follower;
        this.DataBind();
              

                    

    }
}
